<extend name="Public:wap" />
<block name="section-body">
    <div class="container">
        <form role="form" id="myForm"  style="padding-top:60px;" action="{:U('order')}" method="post">
            <div class="panel" >
                <!--商品信息-->
                <div  >
                    <div class="media-left"  style="display:table-cell;vertical-align:middle;">
                        <a href="#">
                            <img class="media-object" src="{$product[icon]}" width="64px" height="64px" alt="{$product[name]}">
                        </a>
                    </div>
                    <div class="media-body"  style="display:table-cell;padding-left:10px;">
                        <h3 class="media-heading">{$product[name]}</h3>
                        <p>{$product[name]}<span class="badge pull-right  alert-danger">{$order[num]}</span></p>
                    </div>
                </div>      

                <div class="form-group" >
                    <p class="alert alert-warning"> 
                        <span class="glyphicon glyphicon-exclamation-sign" ></span>
                        应支付金额:<span class="badge pull-right  alert-danger" id="total-cost">
                            ￥{:sprintf("%.2f",$order[totalfee]/100)}元</span>
                    </p>

                </div>
            </div>
            <div class="panel" >
                <div class="form-group">

                    <if condition="$isweixin eq 1">
                        <a class="btn btn-success btn-block" onclick="callwxpay()">微信支付</a>
                        <else/>
                        <a class="btn btn-default btn-block disabled" >微信支付</a>
                    </if>
                </div>

                <div class="form-group">	

                    <if condition="$isweixin eq 1">
                        <a class="btn btn-default btn-block disabled" >支付宝支付</a>
                        <else/>
                        <a class="btn btn-success btn-block "  onclick="callalipay()">支付宝支付</a>
                    </if>
                </div>


            </div>
        </form> 
    </div>
</block>
<block name="section-script">
    <script type="text/javascript">
        var d = "{$jsApiParameters|default=''}";
        if (!d) {
            d = {};
            alert("jsApiParameters初始化错误");
        }

        function jsApiCall()
        {
            WeixinJSBridge.invoke(
                    'getBrandWCPayRequest',
                    d,
                    function (res) {

                        alert(res.err_msg);
                    }
            );
        }

        function callwxpay()
        {
            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            } else {
                jsApiCall();
            }
        }
    </script>
</block>
